qui(
    function (require, exports, module) {
        VODCom.OCR = {
            CH_CHAR: " ０１２３４５６７８９零一二三四五六七八九".split(""),
            EN_CHAR: " 0123456789".split(""),
            //!"',%():
            REMOVE_SIGN:/[！|＇|＂|“|”|‘|’|，|、|％|（|）|。|．|：|"|'|(|)|.|,|!|:|%|　]/g,
                //" !"',%()".split("").join("|"),
            CH_REGEXP_ARR: [],
            CHAR_LENGTH:1,
            NUM_LENGTH:10,
            REGEXP_LENGTH: 11,
            preDealData: function (inputOrigin, ocrOrigin) {
                var retValue = {
                    inputOrigin: inputOrigin,
                    ocrOrigin: ocrOrigin,
                    inputDeal: null,
                    ocrDeal: null,
                    containsOcr: false,
                    inOcr:false
                }
                var inputDeal = inputOrigin;
                var ocrDeal = ocrOrigin;

                for (var i = 0; i < VODCom.OCR.REGEXP_LENGTH; i++) {
                    inputDeal = inputDeal.replace(VODCom.OCR.CH_REGEXP_ARR[i], VODCom.OCR.EN_CHAR[i]);
                    ocrDeal = ocrDeal.replace(VODCom.OCR.CH_REGEXP_ARR[i], VODCom.OCR.EN_CHAR[i]);
                }
                inputDeal = inputDeal.replace(/ /g,"");
                ocrDeal = ocrDeal.replace(/ /g,"");
                retValue.inputDeal = inputDeal;
                retValue.ocrDeal = ocrDeal;
                retValue.containsOcr = ocrDeal.length > 0 && inputDeal.includes(ocrDeal);
                retValue.inOcr = inputDeal.length > 0 && ocrDeal.includes( inputDeal );
                return retValue
            },
            accountOcrPercent: function (ocrOrigin, inputOrigin) {
                var dealData = this.preDealData(ocrOrigin, inputOrigin);
                if (dealData.containsOcr ||  dealData.inOcr) {
                    return 100;
                }
                var ocrTitle = dealData.ocrDeal;
                var userTitle = dealData.inputDeal
                var retValue = this.innerGetMatrix(ocrTitle, userTitle)
                return   parseInt(100 - 100 * retValue / ( ocrTitle.length > userTitle.length ? ocrTitle.length : userTitle.length ));
            },
            innerGetMin: function (one, two, three) {
                var min = one;
                if (two < min) {
                    min = two;
                }
                if (three < min) {
                    min = three;
                }
                return min;
            },
            innerGetMatrix: function (str1, str2) {
                var n = str1.length;
                var m = str2.length;
                if (n == 0) return m;
                if (m == 0) return n;
                var c1, c2, temp;
                var matrix = {};
                var i = 0, j = 0;
                for (i = 0; i <= n; i++) {
                    matrix[i + "_" + 0] = i;
                }
                for (j = 0; j <= m; j++) {
                    matrix[0 + "_" + j] = j;
                }
                for (i = 1; i <= n; i++) {
                    c1 = str1.charAt(i - 1);
                    for (j = 1; j <= m; j++) {
                        c2 = str2.charAt(j - 1);
                        if (c1 == c2) {
                            temp = 0;
                        } else {
                            temp = 1;
                        }
                        matrix[i + "_" + j] = this.innerGetMin(matrix[(i - 1) + "_" + j] + 1, matrix[i + "_" + (j - 1)] + 1, matrix[(i - 1) + "_" + (j - 1)] + temp);
                    }
                }
                return matrix[n + "_" + m];
            }
        };
        VODCom.OCR.CH_REGEXP_ARR.push(VODCom.OCR.REMOVE_SIGN);
        for (var i = 0; i < VODCom.OCR.NUM_LENGTH; i++) {
            VODCom.OCR.CH_REGEXP_ARR.push(new RegExp(VODCom.OCR.CH_CHAR[1+i]+"|"+VODCom.OCR.CH_CHAR[11+i], "g"));
        }
    }
);